<template xmlns="http://www.w3.org/1999/html">
  <a-modal
    :body-style="bodyStyle"
    :title="title"
    :width="width"
    :visible="visible"
    :confirm-loading="loading"
    :destroy-on-close="true"
    :ok-button-props="{ props: {disabled: disableSubmit} }"
    cancel-text="关闭"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-spin :spinning="spinning">
      <template>
        <div class="app-container">
          <div class="filter-container">
            <a-form-model ref="ruleForm" :model="formModel" layout="inline">
              <a-collapse v-if="collapseKey.collapseForm !== undefined && collapseKey.collapseForm.length > 0" v-model="collapseActiveKey">
                <a-collapse-panel v-for="(collapse) in collapseKey.collapseForm" :key="collapse.key" :header="collapse.head">
                  <a-row v-for="(rowItem ,rowIndex) in formRowCollapseKey[collapse.key]" :key="rowIndex" :gutter="rowItem.gutter">
                    <a-col v-for="(formItem,colIndex) in formRowActiveData[rowItem.rowKey].colList" :key="colIndex" :span="formItem.span">
                      <input-tpl-ui
                        v-show="rowItem.rowType === 'form'"
                        ref="modalFormTplUi"
                        :param-data="initData"
                        :form-item="formColActiveData[formItem.model]"
                        :active-enum-data="activeEnumData"
                        :active-enum-list="activeEnumData[formItem.model]"
                        :modal-fn-data="modalFn"
                        :ui-page-url="uiPageUrl"
                        :init-src-label="initSrcObj.initSrcLabel"
                        :rules="rules"
                        :modal-form="formModel"
                        :form-event="formEvent"
                        :input-style="formItem.inputStyle"
                        @changeEvent="inputChangeEvent"
                        @clearEmpty="clearEmpty"
                      />
                    </a-col>
                  </a-row>
                </a-collapse-panel>
                <a-collapse-panel v-for="(collapse ) in collapseKey.collapseTbl" :key="collapse.key" :header="collapse.head">
                  <tableTplListTemplate
                    :ref="collapse.model"
                    :table-id="collapse.model"
                    :table-event="tableEvent"
                    :param-data="initData"
                    :table-obj-param="tableObjParam"
                    :ui-page-url="uiPageUrl"
                    :init-src-label="initSrcObj.initSrcLabel"
                    @tableChangeEvent="tableChangeEvent"
                    @uiChangeEvent="uiChangeEvent"
                    @openTableLoad="openTableLoad"
                    @openTableMenuLoad="openTableMenuLoad"
                    @openTableMenuSelect="openTableMenuSelect"
                    @openTableMenuDelete="openTableMenuDelete"
                    @openGeneralModal="openGeneralModal"
                    @processCustomRowOnClick="processCustomRowOnClick"
                  />
                </a-collapse-panel>
              </a-collapse>
              <a-row v-for="(rowItem ,rowIndex) in formRowCollapseKey['noCollapseKey']" :key="rowIndex" :gutter="rowItem.gutter">
                <a-col v-for="(formItem,colIndex) in formRowActiveData[rowItem.rowKey].colList" :key="colIndex" :span="formItem.span">
                  <input-tpl-ui
                    v-show="rowItem.rowType === 'form'"
                    ref="modalFormTplUi"
                    :param-data="initData"
                    :form-item="formColActiveData[formItem.model]"
                    :active-enum-data="activeEnumData"
                    :active-enum-list="activeEnumData[formItem.model]"
                    :modal-fn-data="modalFn"
                    :ui-page-url="uiPageUrl"
                    :init-src-label="initSrcObj.initSrcLabel"
                    :rules="rules"
                    :modal-form="formModel"
                    :form-event="formEvent"
                    :input-style="formItem.inputStyle"
                    @changeEvent="inputChangeEvent"
                    @clearEmpty="clearEmpty"
                  />
                </a-col>
              </a-row>
            </a-form-model>
          </div>
          <!--          @change="onStepsChange"-->
          <div v-show="formStepShow">
            <a-steps
              :size="stepsInfo01.size"
              :direction="stepsInfo01.direction"
              @change="onStepsChange"
            >
              <a-step v-for="(stepItem ) in stepList01" :key="stepItem.key" :title="stepItem.title" :status="stepStatusKey01[stepItem.key]">
                <template slot="icon" />
                <span slot="description">{{ stepItem.desc }}
                  <!--                  <a-button  type="primary">审批</a-button>-->
                </span>
              </a-step>
            </a-steps>
            <div class="steps-content">
              <form-tpl-template ref="stepFormTpl" />
            </div>
          </div>
          <formTplModalTemplate
            :ref="formTplModal"
            @reloadLoadData="openTableReload"
          />
          <uiModalTemplate ref="uiModal" @returnQuickSelectRows="returnQuickSelectRows" />
          <treeAndListModalTemplate ref="treeAndListModal" @returnQuickSelectRows="returnQuickSelectRows" />
          <treeNodeModalTemplate ref="treeNodeModal" @returnQuickSelectRows="returnQuickSelectRows" />
          <div v-show="formTabShow" class="card-container ant-card-type-inner">
            <a-tabs v-show="tabsShow01" :key="tabsKey01" :active-key="tabListActiveKey01" @change="onClickTabsCallBack01">
              <a-tab-pane v-for="(tabItem) in tabList01" :key="tabItem.key" :tab="tabItem.tab">
                <form-tpl-template v-if="tabItem.active.S_REF_ID === 'formPanel'" :ref="tabItem.active.S_REF_SHOW_DATA_KEY" />
                <tableTplListTemplate
                  v-if="tabItem.active.S_REF_ID === 'tableTplList01' || tabItem.active.S_REF_ID === 'tableTplList02' || tabItem.active.S_REF_ID === 'tableTplList03'
                        || tabItem.active.S_REF_ID === 'tableTplList04' || tabItem.active.S_REF_ID === 'tableTplList05' || tabItem.active.S_REF_ID === 'tableTplList06'"
                  :ref="tabItem.active.S_REF_SHOW_DATA_KEY"
                  :table-id="tabItem.active.S_REF_SHOW_DATA_KEY"
                  :table-event="tableEvent"
                  :param-data="initData"
                  :table-obj-param="tableObjParam"
                  :init-src-label="initSrcObj.initSrcLabel"
                  :ui-page-url="uiPageUrl"
                  @tableChangeEvent="tableChangeEvent"
                  @uiChangeEvent="uiChangeEvent"
                  @openTableLoad="openTableLoad"
                  @openTableMenuLoad="openTableMenuLoad"
                  @openTableMenuSelect="openTableMenuSelect"
                  @openTableMenuDelete="openTableMenuDelete"
                  @openGeneralModal="openGeneralModal"
                  @processCustomRowOnClick="processCustomRowOnClick"
                />
              </a-tab-pane>
            </a-tabs>

            <a-tabs v-show="tabsShow02" :key="tabsKey02" :active-key="tabListActiveKey02" @change="onClickTabsCallBack02">
              <a-tab-pane v-for="(tabItem) in tabList02" :key="tabItem.key" :tab="tabItem.tab">
                <form-tpl-template v-if="tabItem.active.S_REF_ID === 'formPanel'" :ref="tabItem.active.S_REF_SHOW_DATA_KEY" />
                <tableTplListTemplate
                  v-if="tabItem.active.S_REF_ID === 'tableTplList'"
                  :ref="tabItem.active.S_REF_SHOW_DATA_KEY"
                  :table-id="tabItem.active.S_REF_SHOW_DATA_KEY"
                  :table-event="tableEvent"
                  :param-data="initData"
                  :table-obj-param="tableObjParam"
                  :ui-page-url="uiPageUrl"
                  :init-src-label="initSrcObj.initSrcLabel"
                  @tableChangeEvent="tableChangeEvent"
                  @uiChangeEvent="uiChangeEvent"
                  @openTableLoad="openTableLoad"
                  @openTableMenuLoad="openTableMenuLoad"
                  @openTableMenuSelect="openTableMenuSelect"
                  @openTableMenuDelete="openTableMenuDelete"
                  @openGeneralModal="openGeneralModal"
                  @processCustomRowOnClick="processCustomRowOnClick"
                />
              </a-tab-pane>
            </a-tabs>

            <a-tabs v-show="tabsShow03" :key="tabsKey03" :active-key="tabListActiveKey03" @change="onClickTabsCallBack03">
              <a-tab-pane v-for="(tabItem) in tabList03" :key="tabItem.key" :tab="tabItem.tab">
                <form-tpl-template v-if="tabItem.active.S_REF_ID === 'formPanel'" :ref="tabItem.active.S_REF_SHOW_DATA_KEY" />
                <tableTplListTemplate
                  v-if="tabItem.active.S_REF_ID === 'tableTplList'"
                  :ref="tabItem.active.S_REF_SHOW_DATA_KEY"
                  :table-id="tabItem.active.S_REF_SHOW_DATA_KEY"
                  :table-event="tableEvent"
                  :param-data="initData"
                  :table-obj-param="tableObjParam"
                  :ui-page-url="uiPageUrl"
                  :init-src-label="initSrcObj.initSrcLabel"
                  @tableChangeEvent="tableChangeEvent"
                  @uiChangeEvent="uiChangeEvent"
                  @openTableLoad="openTableLoad"
                  @openTableMenuLoad="openTableMenuLoad"
                  @openTableMenuSelect="openTableMenuSelect"
                  @openTableMenuDelete="openTableMenuDelete"
                  @openGeneralModal="openGeneralModal"
                  @processCustomRowOnClick="processCustomRowOnClick"
                />
              </a-tab-pane>
            </a-tabs>

            <a-tabs v-show="tabsShow04" :key="tabsKey04" :active-key="tabListActiveKey04" @change="onClickTabsCallBack04">
              <a-tab-pane v-for="(tabItem) in tabList04" :key="tabItem.key" :tab="tabItem.tab">
                <form-tpl-template v-if="tabItem.active.S_REF_ID === 'formPanel'" :ref="tabItem.active.S_REF_SHOW_DATA_KEY" />
                <tableTplListTemplate
                  v-if="tabItem.active.S_REF_ID === 'tableTplList'"
                  :ref="tabItem.active.S_REF_SHOW_DATA_KEY"
                  :table-id="tabItem.active.S_REF_SHOW_DATA_KEY"
                  :table-event="tableEvent"
                  :param-data="initData"
                  :table-obj-param="tableObjParam"
                  :ui-page-url="uiPageUrl"
                  :init-src-label="initSrcObj.initSrcLabel"
                  @tableChangeEvent="tableChangeEvent"
                  @uiChangeEvent="uiChangeEvent"
                  @openTableLoad="openTableLoad"
                  @openTableMenuLoad="openTableMenuLoad"
                  @openTableMenuSelect="openTableMenuSelect"
                  @openTableMenuDelete="openTableMenuDelete"
                  @openGeneralModal="openGeneralModal"
                  @processCustomRowOnClick="processCustomRowOnClick"
                />
              </a-tab-pane>
            </a-tabs>
          </div>
        </div>
      </template>
    </a-spin>

    <template slot="footer">

      <a-button v-for="(btnItem,index) in footerToolbarList" v-if="btnItem.compTag === 'button' || btnItem.compTag === 'a'" :key="index" :type="btnItem.type" :disabled="btnItem.disabled" @[btnItem.eventName]="btnOnClick(btnItem)">{{ btnItem.name }}</a-button>
      <!--      <a-button @click="handleCancel">取消</a-button>-->
      <!--      <a-button type="primary">驳回</a-button>-->
      <!--      <a-button type="primary" @click="handleOk">确定</a-button>-->
    </template>

    <!--    <template slot="footer">-->
    <!--      <a-button @click="handleCancel">取消</a-button>-->
    <!--      <a-button type="primary">驳回</a-button>-->
    <!--      <a-button type="primary" @click="handleOk">确定</a-button>-->
    <!--    </template>-->
  </a-modal>
</template>
<script>
// initColShow, changeColShow, changeColKeyShow,
import { changePanelElUiVal } from '@/utils/hypanel'
import { getFnInputParam, handleVerifyErrorTips } from '@/utils/hyurl'
import {
  submitDealReq, loadUIMethod, getDealSubmitParam, getQuickSubmitRemoteData, triggerRefOpenReturn } from '@/utils/auth'
import { changeLoadGeneralModal, getInitLoadUiPageUrlDataParam, openLoadGeneralModal, getChangeInitSrcObj } from '@/utils/hyopen'
import { initEnum, initEnumParam } from '@/utils/hyenum'
import { initFormFnParam, changeFormFnParam, changeFormKeyFnParam, changeFormModelVal, getFormModelKeyData, initFormValue, changeFormValue, changeFormKeyVal,
  initForm, changeForm } from '@/utils/hyform'
import { changeActiveTabData, changeTabListActiveKey, initTabList } from '@/utils/hytabs'
import { initRules, changeFormRules, changeFormKeyRules, initLazyFormRules } from '@/utils/hyformrules'
import { getRemoteUrlParam, initDealApi } from '@/utils/hyurl'
import { inputChangeEventControlObj, getCallFnByFnType, inputChangeEvent, getTplKeyObj } from '@/utils/hyctr'
import { changeInitStepData } from '@/utils/hysteps'
import { initFooterToolbarList, changeFooterToolbarList } from '@/utils/hybtn'
import inputTplUi from './inputTplUi'
import { executeSubmitForm, getCheckRecordKeyStr, getGlobalParam, getQuickSetLocalListData } from '../../../../utils/hyrecord'
import { clickTabsCallBack01, clickTabsCallBack02, clickTabsCallBack03, clickTabsCallBack04 } from '../../../../utils/hytabs'
export default {
  name: 'FormTplModal',
  components: {
    inputTplUi,
    formTplTemplate: () => import('./formTplUi.vue'),
    formTplModalTemplate: () => import('./formTplModal.vue'),
    uiModalTemplate: () => import('./uiModal.vue'),
    tableTplListTemplate: () => import('./tableTplList.vue'),
    treeAndListModalTemplate: () => import('./treeAndListModal.vue'),
    treeNodeModalTemplate: () => import('./treeNodeModal.vue')
  },
  props: ['S_PAGE_ID', 'S_PAGE_VER', 'S_PARTITION', 'tableId'],
  data() {
    return {
      appContainnerCssObj: { appInnerContainerCssClass: 'app-inner-container' },
      globalData: {},
      footerToolbarList: [],
      triggerOpenParam: {},
      initLoadObj: { loadFormId: '', loadBtnId: '', loadListId: '' },
      initSrcObj: { initSrcUrl: 'detail', initSrcLabel: 'detail' },
      tableSelectedRow: [],
      initReturnSetFormData: {},
      initReturnSetListData: {},
      initOpenData: {},
      noCollapseKey: [],
      initCollapse: true,
      collapseActiveKey: [],
      lazyFormRules: {},
      top: 10,
      bottom: 10,
      uidata: {}, // 初始化全部UI数据
      initFormKey: 'formList',
      initTableKey: 'formPanel',
      initUiVal: {},
      remoteDataSet: {},
      showTableTplKey: 'tableTplList',
      showTableNowKey: null,
      isNew: false,
      spinning: true,
      loading: false,
      inputStyle: 'width: 360px',
      screenWidthFix: 1.1,
      inputWidthFix: 0.75,
      buttonLoading: false,
      buttonDisabled: false,
      width: this.initWidth(),
      title: '操作0',
      bodyStyle: { padding: '0px' },
      modalVisible: false,
      lang: 'zh',
      tableObjParam: { rowOnClick: false, selectFirstRow: 'selectFirstRow', defalutSearchQuery: 'searchQuery' },
      tableEvent: { update: 'openTableMenuUpdate', delete: 'openTableMenuDelete', insert: 'openTableMenuInsert',
        select: 'openTableMenuSelect', copy: 'openTableMenuCopy', detail: 'openTableMenuDetail',
        selectNode: 'openTableMenuSelectNode', load: 'openTableLoad', menuLoad: 'openTableMenuLoad',
        tableModal: 'openTableModal', menuModal: 'openTableMenuModal', generalModal: 'openGeneralModal',
        setData: 'openSetDataTableModal', saveSearchForm: 'saveTableSearchForm', rowOnClick: 'processCustomRowOnClick' },
      nowBtnItem: {},
      openBtnItem: {},
      uiPageUrl: {},
      openParam: {},
      localParam: {},
      parentRefOpen: {},
      nowRow: {},
      urlKey: '',
      data: [],
      value: [],
      fetching: false,
      formModel: {},
      // record: {},
      initData: {},
      enumParam: {},
      // formList: [],
      collapseKey: {},
      formKey: [],
      modalFn: {},
      modalFnShow: {},
      modalFnData: {},
      formEvent: {},
      rules: {},
      disableSubmit: false,
      disabled: false,
      visible: false,
      formTplModal: 'formTplModal',
      enumData: {},
      activeEnumData: {},
      formRowCollapseKey: {},
      formRowActiveData: {},
      formColActiveData: {},
      formRowData: {},
      formColData: {},
      formStepShow: false,
      steps: {},
      stepsKey01: 'steps01',
      stepsActiveKey01: 'leader',
      stepStatusKey01: { create: 'finish', leader: 'process', manager: 'wait' },
      stepsInfo01: {},
      stepList01: [],
      stepCurrent: 0,
      stepInfo: {},
      stepList: [],
      stepActiveInfo: {},
      stepListActiveKey: 1,
      formTabShow: false,
      tabsActvieObj: {},
      tabInfo: {},
      tabs: {},
      tabsShow01: false,
      tabsKey01: 'tabs01',
      tabListObj01: {},
      tabList01: [],
      tabListActiveKey01: null,

      tabsShow02: false,
      tabsKey02: 'tabs02',
      tabListObj02: {},
      tabList02: [],
      tabListActiveKey02: null,

      tabsShow03: false,
      tabsKey03: 'tabs03',
      tabListObj03: {},
      tabList03: [],
      tabListActiveKey03: null,

      tabsShow04: false,
      tabsKey04: 'tabs04',
      tabListObj04: {},
      tabList04: [],
      tabListActiveKey04: null,

      validatorCommRules: {
        S_COMMON_RULE: {
          rules: [{
            required: false
          }]
        }
      },
      dealParam: {
        init: { S_DY_PARAM: [] }
      },
      dealApi: {
        init: { S_PAGE_ID: '', S_PAGE_VER: '', S_PARTITION: 32 }
      }
    }
  },
  computed: {
    isVisible: {
      get() {
        return this.dialogVisible
      },
      set() {
        this.close()
        this.reset()
      }
    }
  },
  mounted() {
  },
  created() {
    const _this = this
    _this.openParam = Object.assign({}, _this.openParam, _this.$route.query)
  },
  methods: {
    change(affixed) {
      console.log(affixed)
    },
    initUI(val, param, initSrcObj) {
      const _this = this
      if (val === undefined) {
        return
      }
      console.log('model...val',val)
      _this.initLoadObj.loadPanelId = val.panel.panelTplId
      _this.initLoadObj.loadPanelVer = val.panel.panelTplVer
      _this.initLoadObj.panelWidth = val.panel.panelWidth
      _this.initLoadObj.defPanelWidth = 100
      _this.globalData.tableId = _this.tableId
      _this.globalData.initSrcObj = _this.initSrcObj
      _this.globalData.clickRow = {}
      _this.globalData.clickItem = {}
      _this.globalData.openParam = _this.openParam
      _this.globalData.formModel = _this.formModel
      _this.globalData.initData = _this.initData
      _this.globalData.tableSelectedRow = []
      _this.globalData.globalParam = getGlobalParam(_this)
      this.openParam = param
      this.initUiVal = val
      this.initSrcObj = initSrcObj
      initLazyFormRules(this)
      this.initFormFnParam(false)
      this.initEnumParam()
      this.initRules()
      this.initForm()
      this.initFormValue()
      initTabList(this)
      // initSteps(this)
      initFooterToolbarList(this)
      this.spinning = false
      // this.clearUiData()
      initDealApi(this, val)
      _this.initFormObjValue(param)
      this.collapseActiveKey = Object.assign([], this.formList.collapseActiveKey)
      _this.$nextTick(() => {
        // _this.changeFormValue(param)
        changeFooterToolbarList(_this, null, _this.globalData)
        changeFormValue(_this, _this.globalData)
        _this.changeFormRules()
        // _this.changeColShow()
        _this.changeFormFnParam()
        changeTabListActiveKey(_this)
        changeInitStepData(_this, _this.globalData)
        _this.changeInitCollapseTable(_this.globalData)
        // _this.$nextTick(() => {
        //   _this.changeActiveTabData()
        // })
      })
    },
    otherCompSetValClearData() {
      const thisObj = this
      const tmpData = Object.assign({})
      thisObj.initData = Object.assign(tmpData)
      thisObj.openReturnData = Object.assign(tmpData)
      thisObj.formModel = Object.assign(tmpData)
      thisObj.globalData = Object.assign(tmpData)
    },
    otherCompSetValOpenParam(triggerObj, param, initSrcObj) {
      const thisObj = this
      this.otherCompSetValClearData()
      // this.initSrcLabel = param.initSrcLabel
      this.openParam = Object.assign({}, param)
      thisObj.formModel = Object.assign({}, this.openParam, param)
      thisObj.initFormData(thisObj.initSrcLabel)
    },
    changeFormRowData() {
      this.formRowData = this.initUiVal.formList.rowData
    },
    changeFormColData() {
      this.formColData = this.initUiVal.formList.colData
    },
    initFormData(urlKey) {
      const _this = this
      const formKeyData = getFormModelKeyData(_this)
      const record = Object.assign({}, _this.openParam, formKeyData)
      const param = getRemoteUrlParam(_this, urlKey, record)
      _this.loading = true
      submitDealReq(param).then((res) => {
        _this.loading = false
        if (res.data.success) {
          _this.changeInitFormData(res.data.data)
          _this.$message.success(res.data.message)
        } else {
          _this.$message.warning(res.data.message)
        }
      })
    },
    changeInitFormData(remoteData) {
      const thisObj = this
      const record = Object.assign({}, thisObj.openParam, remoteData)
      thisObj.initData = Object.assign({}, record)
      thisObj.nowRow = Object.assign({}, record)
      thisObj.handleEdit(record)
      changeActiveTabData(thisObj)
    },
    initTableUi(data) {
      const thisObj = this
      thisObj.showTableNowKey = null
      thisObj.uidata = Object.assign({}, data)
    },
    changeTableUi(tplKey, param, newInitSrcObj) {
      const thisObj = this
      const panelEl = changePanelElUiVal(thisObj.uidata, tplKey, param)
      if (panelEl !== null) {
        const showKey = panelEl.dataKey
        const tplGlobalData = {}
        tplGlobalData.globalParam = param
        tplGlobalData.openParam = param
        const newParam = getFnInputParam(thisObj, tplGlobalData, panelEl.refSetVal)
        console.debug('切换面板', '模板变量', tplKey, '数据变量', showKey, '绑定参数', newParam, '入参', panelEl.refSetVal)
        // const tableData = thisObj.globalData[tplKey]
        // if (tableData !== undefined && tableData.length > 0) {
        //   newParam.tableData = tableData
        // }
        const initSrcPanelElObj = getChangeInitSrcObj(thisObj, panelEl, newInitSrcObj)
        console.log('newInitSrcObj',newInitSrcObj,'initSrcPanelElObj',initSrcPanelElObj)
        thisObj.changeTableUiKey(tplKey, showKey, newParam, initSrcPanelElObj)
      }
    },
    changeTableUiKey(tplKey, showKey, param, initSrcObj) {
      // console.debug('切换面板','模板变量', tplKey, '数据变量', showKey, '参数', param)
      // 做一个面板里面多个table数据切换
      param.initSrcLabel = this.initSrcLabel
      const thisObj = this
      const tplKeyObj = getTplKeyObj(thisObj, tplKey)
      if (thisObj.showTableNowKey !== showKey) {
        thisObj.showTableNowKey = showKey
        const initUiVal = thisObj.uidata[showKey]
        if (initUiVal !== null) {
          tplKeyObj.initUI(initUiVal, param, initSrcObj)
          tplKeyObj.otherCompSetValOpenParam(null, param, initSrcObj)
        } else {
          tplKeyObj.otherCompSetValOpenParam(null, param, initSrcObj)
        }
      } else {
        tplKeyObj.otherCompSetValOpenParam(null, param, initSrcObj)
      }
    },
    tableChangeEvent(formItem, triggerObj, localParamDataSet, selectedRow) {
      const thisObj = this
      console.log('表格变化统一formItem.', formItem)
      console.log('表格变化统一事件接口.', triggerObj)
      console.log('表格变化统一事件接口 localParamDataSet.', localParamDataSet)
      console.log('表格变化统一事件接口 selectedRow.', selectedRow)
      // const changeOpenParam = this.openParam
      // changeOpenParam 做入参适配
      const changeOpenParam = localParamDataSet
      thisObj.tableChangeEventControlObj(formItem, triggerObj, changeOpenParam)
    },
    tableChangeEventControlObj(formItem, triggerObj, changeOpenParam) {
      const thisObj = this
      const I_TRIGGER_OBJ = triggerObj.i_TRIGGER_OBJ
      if (I_TRIGGER_OBJ === 7) {
        // 执行面板呈现规则
        thisObj.showTableIdKey = triggerObj.showKey
        thisObj.changeTableUi(thisObj.showTableIdKey, changeOpenParam)
      } else {
        console.log('表格变化统一控制事件接口.', triggerObj)
      }
    },
    uiChangeEvent(formItem, triggerObj, localParamDataSet, selectedRow) {
      console.log('ui change event...', triggerObj)
    },
    initEnumParam() {
      const thisObj = this
      initEnumParam(thisObj)
    },
    initForm() {
      const thisObj = this
      initForm(thisObj)
    },
    changeForm(triggerObj, param) {
      const thisObj = this
      changeForm(thisObj, triggerObj, param)
    },
    initRules() {
      // 开始初始化所有项目为必填
      const thisObj = this
      initRules(thisObj)
    },
    changeFormRules() {
      // 加载结束后,根据规则调整对应表单校验方式
      const thisObj = this
      changeFormRules(thisObj)
    },
    changeFormKeyRules(key) {
      // 单个变量校验规则调整设置
      const thisObj = this
      changeFormKeyRules(thisObj, key)
    },
    initFormFnParam() {
      // 一开始初始化读写参数
      const thisObj = this
      initFormFnParam(thisObj, true)
    },
    changeFormFnParam() {
      // 设置初始加载表单读写参数
      const thisObj = this
      changeFormFnParam(thisObj, thisObj.initSrcObj.initSrcLabel)
    },
    changeFormKeyFnParam(key) {
      const thisObj = this
      changeFormKeyFnParam(thisObj, key, thisObj.initSrcObj.initSrcLabel)
    },
    initFormValue() {
      // 一开始初始化读写参数
      const thisObj = this
      initFormValue(thisObj)
    },
    changeFormValue(openParam) {
      // 设置初始加载表单读写参数
      const thisObj = this
      changeFormValue(thisObj, openParam)
    },
    changeFormKeyValue(key, objData) {
      const thisObj = this
      changeFormKeyVal(thisObj, key, objData)
    },
    changeInitCollapseTable(param) {
      const _this = this
      const formList = Object.assign({}, _this.initUiVal[_this.initFormKey])
      if (formList.collapseKey === undefined) {
        return
      }
      if (formList.collapseKey.collapseTbl === undefined) {
        return
      }
      if (formList.collapseKey.collapseTbl.length > 0) {
        _this.$nextTick(() => {
          for (const key in formList.collapseKey.collapseTbl) {
            const tblTmpData = formList.collapseData.collapseTbl[key]
            const tplKey = tblTmpData.model
            if (_this.$refs[tplKey] === undefined) {
              return
            }
            if (_this.$refs[tplKey] !== undefined) {
              _this.changeTableUi(tplKey, param)
            }
          }
        })
      }
    },
    changeStepStatusKey01() {
      this.stepStatusKey01['create'] = 'process'
    },
    onClickTabsCallBack01(key) {
      console.log('onClickTabsCallBack01', key)
      const tmpGlobalData = this.globalData
      clickTabsCallBack01(this, key, tmpGlobalData)
    },
    onClickTabsCallBack02(key) {
      console.log('onClickTabsCallBack', key)
      const tmpGlobalData = this.globalData
      clickTabsCallBack02(this, key, tmpGlobalData)
    },
    onClickTabsCallBack03(key) {
      console.log('onClickTabsCallBack', key)
      const tmpGlobalData = this.globalData
      clickTabsCallBack03(this, key, tmpGlobalData)
    },
    onClickTabsCallBack04(key) {
      console.log('onClickTabsCallBack', key)
      const tmpGlobalData = this.globalData
      clickTabsCallBack04(this, key, tmpGlobalData)
    },
    onStepsChange(current) {
      console.log('onStepsChange', current)
      // this.stepCurrent = current
      // this.stepActiveInfo = this.stepList[this.stepCurrent]
      // this.changeStepActiveForm()
    },
    inputChangeEventControlObj(formItem) {
      const thisObj = this
      thisObj.globalData.tableId = thisObj.tableId
      thisObj.globalData.initSrcObj = thisObj.initSrcObj
      thisObj.globalData.clickRow = {}
      thisObj.globalData.clickItem = formItem
      thisObj.globalData.openParam = thisObj.openParam
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.activeEnumData = thisObj.activeEnumData
      thisObj.globalData.tableSelectedRow = []
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      inputChangeEventControlObj(thisObj, formItem, thisObj.globalData)
    },
    ccccc(cc) {
      if (this.showObj.test) {
        this.showObj.test = false
      } else {
        this.showObj.test = true
      }
      // console.log('ccccc',this.modalFnData);
      // let key = 'test';
      // this.modalFnData[key] = 1
      //  console.log('this.validatorRules',this.validatorRules);
    },
    initWidth() {
      return '750px'
    },
    close() {
      const tmpData = Object.assign({})
      this.formModel = Object.assign(tmpData)
      this.$emit('close')
    },
    reset() {
      // this.$refs.form.clearValidate()
      // this.$refs.form.resetFields()
    },

    clearEmpty(item) {
      console.log('00000000000000', item)
    },
    // getRefOpenObj(text, record, rowIndex, rowColumn) {
    //   return getRefOpenObj(text, record, rowIndex, rowColumn)
    // },
    // onInputChange(formItem) {
    //   // console.log('modal ....onInputChange formItem', formItem)
    // },
    inputChangeEvent(formItem) {
      const thisObj = this

      thisObj.globalData.tableId = thisObj.tableId
      thisObj.globalData.initSrcObj = thisObj.initSrcObj
      thisObj.globalData.clickRow = {}
      thisObj.globalData.clickItem = formItem
      thisObj.globalData.openParam = thisObj.openParam
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.activeEnumData = thisObj.activeEnumData
      thisObj.globalData.tableSelectedRow = []
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      console.log('inputChangeEvent', formItem, thisObj.globalData)
      inputChangeEvent(thisObj, formItem)
    },
    inputOpenGeneralModal(formItem, globalData) {
      this.openGeneralModal(formItem, globalData)
    },
    openGeneralModal(btnItem, globalData) {
      openLoadGeneralModal(btnItem, globalData, this)
    },
    returnQuickSelectRows(selectRows, formItem) {
      const thisObj = this
      console.debug(formItem, 'selectRows', selectRows)
      triggerRefOpenReturn(selectRows, formItem, thisObj)
    },
    returnQuickSetLocalFormData(selectionRows, formItem) {
      // 设置本地临时表单数据
      const checkObj = getCheckRecordKeyStr(selectionRows)
      this.initFormObjValue(checkObj)
    },
    returnQuickSetLocalListData(selectionRows, formItem) {
      const thisObj = this
      getQuickSetLocalListData(selectionRows, formItem, thisObj)
    },
    returnQuickSubmitRemoteData(selectionRows, formItem) {
      const thisObj = this
      // 设置提交远程列表数据
      if (selectionRows.length !== 0) {
        const tableId = thisObj.getShowKeyTableId(thisObj, formItem)
        const tplObj = getTplKeyObj(thisObj, tableId)
        // 设置提交远程列表数据
        const tmpGlobalData = tplObj.globalData
        getQuickSubmitRemoteData(selectionRows, tmpGlobalData, formItem, thisObj)
      }
    },
    getShowKeyTableId(thisObj, openBtnItem) {
      const panelTplId = openBtnItem.panelTplId
      return thisObj.uidata.showKeyData[panelTplId]
    },
    getFormVal() {
      return getFormModelKeyData(this)
    },
    processCustomRowOnClick(record) {
      this.nowRow = record
      console.log('processCustomRowOnClick @@@@', record)
    },
    clearUiData() {
      this.formTabShow = false
      this.tabList = Object.assign([])
    },
    initFormObjValue(record) {
      const cc = Object.assign({}, this.formModel, record)
      this.formModel = Object.assign({}, cc)
    },
    tableOperatorBtnOnClick(btnItem) {
      const fn = btnItem.fn
      console.log('tableOperatorBtnOnClick', btnItem)
      //  this[fn](this.tableSelectedRow);
    },
    openTableMenuSelect(selected) {

    },
    onChange(time) {
      console.log(time)
      this.value = time
    },
    callParentPageFun() {
      this.$emit('reloadTreeOnLoadRootData')
    },
    handleInit(copyRecord, pageObj, initRecord) {
      const _this = this
      const urlKey = this.globalData.initSrcObj.initSrcUrl
      const param = getRemoteUrlParam(_this, urlKey, _this.globalData)
      _this.loading = true
      submitDealReq(param).then((res) => {
        if (res.data.success) {
          const record = Object.assign({}, initRecord, copyRecord, res.data.data)
          _this.initData = Object.assign({}, record)
          _this.globalData.initData = _this.initData
          changeFormModelVal(_this, record)
          _this.initStepStauts(record)
          _this.changeInitCollapseTable(record)
          changeActiveTabData(_this)
          _this.globalData.globalParam = getGlobalParam(_this)
          initEnum(_this, this.globalData)
          _this.loading = false
          _this.$message.success(res.data.message)
        } else {
          _this.$message.warning(res.data.message)
        }
      })
    },
    initStepStauts(record) {
      let activeIdx = 0
      this.stepsActiveKey01 = record.S_RUN_ACT_CODE
      this.stepStatusKey01[ this.stepsActiveKey01] = 'process'
      // { create: 'finish', leader: 'process', manager: 'wait' },
      const stepListKey = this.stepsInfo01.stepListKey
      for (const i in stepListKey) {
        const key = stepListKey[i]
        this.stepStatusKey01[ key] = 'finish'
        if (this.stepsActiveKey01 === key) {
          activeIdx = i
          this.stepStatusKey01[ this.stepsActiveKey01] = 'process'
        }
        if ((i > activeIdx) && activeIdx !== 0) {
          this.stepStatusKey01[ key] = 'wait'
        }
      }
    },
    handleEdit(record) {
      const _this = this
      changeFormModelVal(_this, record)
    },
    showGeneralModal(btnItem, uidata, openParam) {
      if (undefined === uidata) {
        return
      }
      const triggerRefOpenData = btnItem.refOpen.triggerRefOpenData
      this.openParam = openParam
      this.isNew = false
      if (triggerRefOpenData.refObjUrlKey === undefined) {
        triggerRefOpenData.refObjUrlKey = 'init'
      }
      if (triggerRefOpenData.refObjUrlKey === 'init' || triggerRefOpenData.refObjUrlKey === 'empty' || triggerRefOpenData.refObjUrlKey === 'copy') {
        this.isNew = true
      }
      this.visible = true
      this.record = Object.assign({}, openParam)
      this.initUI(uidata, openParam, this.initSrcObj)
      const objSetVal = btnItem.refOpen.objSetVal
      const postParam = getFnInputParam(this, this.globalData, objSetVal)
      this.handleInit(postParam, this.dealApi[triggerRefOpenData.refObjUrlKey], openParam)
    },
    showLoadGeneralModal(btnItem, refOpen, record) {
      const _this = this
      // _this.initOpenData =
      changeLoadGeneralModal(_this, btnItem, refOpen, record)
      const param = getInitLoadUiPageUrlDataParam(_this)
      _this.spinning = true
      _this.loading = true
      // _this.isVisible = true
      loadUIMethod(param).then((res) => {
        if (!res.data.success) {
          _this.spinning = false
          _this.loading = false
          _this.disableSubmit = true
          _this.$message.success(res.data.message)
          return
        }
        const val = Object.assign({}, res.data.data)
        _this.initTableUi(res.data.data)
        _this.spinning = false
        _this.$nextTick(() => {
          const newUiData = val[refOpen.refObjDataKey]
          const newBtnItem = Object.assign({}, btnItem)
          newBtnItem.urlKey = refOpen.refObjUrlKey
          newBtnItem.fnKey = refOpen.refObjFnKey
          _this.showGeneralModal(newBtnItem, newUiData, _this.openParam)
          _this.isVisible = true
          // _this.loading = false
          if (newBtnItem.fnKey === 'detail') {
            _this.disableSubmit = true
          } else {
            _this.disableSubmit = false
          }
        })
      })
    },
    openTableReload(openBtnItem, returnData, modalKey, modalForm) {
      this.reloadLoadData(openBtnItem, returnData, 'remoteData', modalForm)
    },
    // saveTableSearchForm(record) {
    //
    // },
    // saveTableDownSearchForm(record) {
    //
    // },
    // openTableSearch(btnItem, record) {
    //   this.nowBtnItem = btnItem
    //   const selectedRecord = Object.assign({}, record)
    //   this.treeCleanChildrenNode(selectedRecord)
    //   this.$refs[this.nowBtnItem.tableId].tableQueryByParam(selectedRecord)
    // },
    //
    // openTableMenuDelete(btnItem, record) {
    //   this.nowBtnItem = btnItem
    //   console.log('openTableMenuDelete', record)
    // },
    //
    // openTableMenuSelectNode(btnItem, record) {
    //   this.nowBtnItem = btnItem
    //   console.log('openTableMenuSelectNode', record)
    // },
    // openTableLoad(btnItem, record) {
    //   const _this = this
    //   // _this.$refs[this.tabListActiveKey][0].tableQueryByParam(_this.initData);
    // },
    // openTableMenuLoad(btnItem, record) {
    //   console.log('openTableMenuLoad', record)
    //   // this.openTableDownSearch(record);
    // },
    // getDealParam(dealKey, values) {
    //   const _this = this
    //   const postParam = getDealSubmitParam(_this, dealKey, values,
    //     _this.dealApi, _this.dealParam, this.initData, {})
    //   return postParam
    // },
    handleVerifyError(result) {
      const thisObj = this
      handleVerifyErrorTips(thisObj, result)
    },
    reloadLoadData(formItem, data, modalKey, postParam) {
      console.log('reloadLoadData', data, modalKey)
      // 远程调用成功
      if (modalKey === 'remoteData') {
        changeActiveTabData(this)
      }
    },
    handleOk() {
      const _this = this
      console.log('initSrcObj',_this.initSrcObj)
      this.$refs.ruleForm.validate((valid, values) => {
        if (valid) {
          let key = ''
          if (_this.isNew) {
            key = 'insert'
          } else {
            key = 'update'
          }
          const formKeyData = getFormModelKeyData(_this)
          _this.globalData.tableId = _this.tableId
          _this.globalData.initSrcObj = _this.initSrcObj
          _this.globalData.clickRow = {}
          _this.globalData.clickItem = {}
          _this.globalData.openParam = _this.openParam
          _this.globalData.formModel = _this.formModel
          _this.globalData.initData = _this.initData
          _this.globalData.activeEnumData = _this.activeEnumData
          _this.globalData.tableSelectedRow = []
          _this.globalData.globalParam = getGlobalParam(_this)

          const param = getRemoteUrlParam(_this, key, _this.globalData)
          console.log('_this.globalData', param, _this.globalData, param)
          _this.loading = true
          submitDealReq(param).then((res) => {
            _this.loading = false
            if (res.data.success) {
              _this.remoteDataSet = res.data
              _this.isNew = false
              _this.$message.success(res.data.message)
              _this.clearData()
              _this.$emit('reloadLoadData', _this.triggerOpenParam.openBtnItem, res.data, key, formKeyData)
              _this.visible = false
              _this.$emit('close')
            } else {
              console.log('提交异常结果', res.data)
              _this.$message.warning(res.data.message)
              _this.handleVerifyError(res.data)
            }
          })
        } else {
          const result = {}
          const data = []
          for (const key in values) {
            const obj = values[key]
            for (const idx in obj) {
              const item = {}
              item.verifyResult = obj[idx].message
              data.push(item)
            }
          }
          result.resultMsg = '表单校验失败'
          result.data = data
          _this.handleVerifyError(result)
          return false
        }
      })
    },
    clearData() {
      const tmpData = Object.assign({})
      this.initUiVal = Object.assign(tmpData)
      this.initData = Object.assign(tmpData)
      this.nowRow = Object.assign(tmpData)
      this.openParam = Object.assign(tmpData)
      this.formModel = Object.assign(tmpData)
      this.formTabShow = false
      this.tabList = []
      this.tabListActiveKey = null
      this.formStepShow = false
      this.steps = Object.assign(tmpData)
      this.stepList01 = []
      this.stepsInfo01 = {}
      this.footerToolbarList = []
      this.globalData = Object.assign(tmpData)
    },
    handleCancel() {
      const _this = this
      _this.clearData()
      _this.$emit('close')
      _this.visible = false
      /** *
       _this.$confirm({
      title: "确认关闭",
      content: "编辑数据将会丢失，确认关闭?",
      onOk: function () {
          _this.visible = false;
         _this.$emit('close');
      }
    });
       **/
    },
    btnOnClick(btnItem) {
      const _this = this
      console.log('btnItem', btnItem)
      if (btnItem.fnType === 98) {
        this.handleCancel()
      } else if (btnItem.fnType === 3 || btnItem.fnType === 15 || btnItem.fnType === 16 || btnItem.fnType === 17 || btnItem.fnType === 18) {
        this.$refs.ruleForm.validate((valid, values) => {
          if (valid) {
            _this.loading = true
            _this.globalData.tableId = _this.tableId
            _this.globalData.initSrcObj = _this.initSrcObj
            _this.globalData.clickRow = {}
            _this.globalData.clickItem = {}
            _this.globalData.openParam = _this.openParam
            _this.globalData.formModel = _this.formModel
            _this.globalData.initData = _this.initData
            _this.globalData.activeEnumData = _this.activeEnumData
            _this.globalData.tableSelectedRow = []
            _this.globalData.globalParam = getGlobalParam(_this)
            executeSubmitForm(_this, btnItem, _this.globalData)
          } else {
            const result = {}
            const data = []
            for (const key in values) {
              const obj = values[key]
              for (const idx in obj) {
                const item = {}
                item.verifyResult = obj[idx].message
                data.push(item)
              }
            }
            result.resultMsg = '表单校验失败'
            result.data = data
            _this.handleVerifyError(result)
            return false
          }
        })
      }
      const fn = getCallFnByFnType(btnItem)
      console.log(btnItem, 'fn....', fn)
      // if (fn === 'openGeneralModal') {
      //   this[fn](btnItem, this.triggerOpenParam.openParam)
      // }
    }
  }
}
</script>
<style lang="less" scoped>
</style>
